function jyyMain(){
}

var userId = "";
jyyMain.config = {};
jyyMain.init = function(){
	//this.initParam();
	//this.load();
	this.initEvent();
};
jyyMain.getScreen = function(){
	
	var project = parent.getSelectScheme().code;
	
	parent.window.open('screen.html?project='+project);
};
//初始化参数
/*jyyMain.initParam = function(){
	//获取登录用户信息
	var resdata ={mainUrl: "app.main",
			name: "王金国",
			organCode: "000000",
			organName: "国网经研院",
			type: "1",
			user: "1",
			userName: "GWY"};
	jyyMain.user = resdata;
	
	
	//初始化方案列表数据
   	$.ajax({
   		async: false,
		dataType: "json",
		data:{"addUser":jyyMain.user.userName},
		url: "../pv/main/getSchemeList"
	}).done(function(res) {
		var scheme = eval("("+res+")");
		jyyMain.scheme = scheme;
	});
};*/
//加载
jyyMain.load = function(){
	//加载方案列表
	jyyMain.tree = RxTree.init("schemeTree", jyyMain.scheme, {listMode:"tree"}, {top:"0px", left:"0px", right:"0px", bottom:"0px", border:"none",borderRight: "1px solid #e0e0e0"}, jyyMain.onTreeEvent);
	jyyMain.tree.expandLevel(1);
	//加载圆形进度条
	//this.circleBar = JyyCircleBar.init("circle", {value:0, width:6, color:"#353535", image:["images/powetower.png", "images/powetower-schedule.png"], fgColor:"#0ed4a1", bgColor:"#928e7d", isShowProgress:false}, {top:"50%", left:"50%", marginTop:"-65px", marginLeft:"-65px", width:"130px", height:"130px"}, null);
};
//初始化事件
jyyMain.initEvent = function(){
	//JyyRadio.init("radio_mode1", "mode", true, null, "运行方式01", {top:"5px",left:"10px",width:"100px"}, jyyMain.onRadioClick);
	//JyyRadio.init("radio_mode2", "mode", false, null, "运行方式02", {top:"31px",left:"10px",width:"100px"}, jyyMain.onRadioClick);
	
	$.ajax({
		url: "g/service/Sample/getUserId",
		type:'POST',
		cache:false,
		async:false,
		dataType: "json",
		contentType:"application/json",
	    success:function(data){
	    	userId = data;
	    }
	});
	$(".module_show").click(function(){
		jyyMain.isShow = true;
		$(".mode_panel").show();
	});
	$(".mode_show").click(function(){
		jyyMain.isShow = true;
		$(".mode_panel").hide();
	});
	$(".module_title").click(function(){
		var self = this;
		if(jyyMain.isShow){
			jyyMain.isShow = false;
			return;
		}
		var parentId = $(this).parent().attr("id");
		$(".module_title").filter(function(index, ob){
			return !(ob == self);
			
		}).each(function(index, ob){
			if(ob.isClick){
				ob.isClick = false;
				$(ob).parent().find("ul").css({display:"none"});
				if(parentId == "circle-source" || parentId == "circle-bpa"){
					$(ob).css({"top":"45%"});
				}else{
					$(ob).css({"top":"40%"});
				}
			}
		})
		if(this.isClick){
			this.isClick = false;
			$(this).parent().find("ul").css({display:"none"});
			if(parentId == "circle-source" || parentId == "circle-bpa"){
				$(this).css({"top":"45%"});
			}else{
				$(this).css({"top":"40%"});
			}
		}else{
			this.isClick = true;
			$(this).parent().find("ul").css({display:"inline"});
			if(parentId == "circle-source" || parentId == "circle-bpa"){
				$(this).css({"top":"0px"});
			}else{
				$(this).css({"top":"10px"});
			}
		}
	});
	$("div[name='module']").mouseenter(function(){//模块移入改变背景色
		$(this).find(".module_title").css({"background":"url(images/label-bg.png) center center /cover no-repeat", "color":"white"});
		$(".module_image").css({"display":"none"});
		$("." + this.id).css({"display":"inline"});
		
	}).mouseleave(function(){
		$(this).find(".module_title").css({"background":"none", "color":"#333"});
		
	}).find("li").on("click", jyyMain.onMainClick);
};
/** ------------------------------方案列表-start-----------------------------------**/
//方案列表点击事件
jyyMain.onTreeEvent = function(res){
	if(res.name == "onrefresh"){
		return;
	}
	if(res.name == "oncontextmenu"){
		var level = res.node.data.level;
		var menuData = null;
		if(level == 1){
			menuData = JyyMenu.NODE1_MENU;
		}else if(level == 2){
			menuData = JyyMenu.NODE2_MENU;
		}else if(level == 3){
			menuData = JyyMenu.NODE3_MENU;
		}else if(level == 4){
			menuData = JyyMenu.NODE4_MENU;
		}
		
		var jyymenu = new JyyMenu(menuData, jyyMain.onQueryMenuClick);
		jyymenu.show({event:res.e, data:res.node});
	}else if(res.name == "onclick"){
		var data = res.node.data;
		if(data.level == 1){
			parent.setSelectScheme(null, null);jyyMain.selectScheme = null;
		}else if(data.level == 2){
			parent.setSelectScheme2(null, null);
			parent.setSelectScheme(data, null);jyyMain.selectScheme = data;
		}else if(data.level == 3){
			var parentData = res.node.nodeli.data;
			parent.setSelectScheme2(res.node.data, data)
			parent.setSelectScheme(parentData, data);jyyMain.selectScheme = data;
		}else if(data.level == 4){
			var parentData = res.node.nodeli.nodeli.data;
			parent.setSelectScheme2(res.node.parentNode._owner.data, data)
			parent.setSelectScheme(parentData, data);jyyMain.selectScheme = data;
		}
	}
}
//方案列表右击菜单点击事件
jyyMain.onQueryMenuClick = function(res,node){
	if(res.id == "newScheme"){
		jyyMain.setScheme("新建方案",node);
		
	} else if(res.id == "newBpaScheme"){//新建场景
	//	scheme.init(null, node.data.data);
		jyyMain.setBpaScheme("新建方案",node);
		
	} else if(res.id == "updateScheme"){
		jyyMain.setScheme("修改方案",node);
		
	} else if(res.id == "deleteScheme"){
		JyyMsgBox.confirm({ title:"提示", message:"确定删除方案？",type:"warning"}).on(function (e) {
			if (e) {
				jyyMain.deleteScheme(node);
			}
		});
	} else if(res.id == "addShareUser"){
		jyyMain.addShare();
		
	} else if(res.id == "clearShareUser"){
		jyyMain.clearShare();
		
	} else if(res.id == "updateBpaScheme"){
		scheme.init(node.data.data, node.data.nodeli.data);
		
	} else if(res.id == "deleteBpaScheme"){
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			JyyMsgBox.confirm({ title:"提示", message:"确定删除子方案？",type:"warning"}).on(function (e) {
				if (e) {
					//scheme.del(node.data.data.code,node.data.nodeli.data.code);
					scheme.del(node);
					jyyMain.deleteListScheme2(node);
				}
			});
		}
	}else if(res.id == "updateSchemeName"){
		
		//scheme.handle(node.data.data, node.data.nodeli.data);
		jyyMain.setListScheme("修改方案名称",node);
		
	}else if(res.id == "deleteListScheme"){
		//jyyMain.deleteListScheme(node);
		JyyMsgBox.confirm({ title:"提示", message:"确定删除方案？",type:"warning"}).on(function (e) {
			if (e) {
				jyyMain.deleteListScheme(node);
			}
		});
		
	}
}
//删除三级方案
jyyMain.deleteListScheme = function(node) {
	//debugger
//var parentData = res.node.nodeli.data;
    var schemeid=node.data.nodeli.nodeli.data.code;
	var versionid=node.data.nodeli.data.code;
	var resultid = node.data.data.code;
	var username = jyyMain.user.userName;
	

	if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
		JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
	}else{
		JyyLoading.start();
		$.ajax({
	   		async: false,
			dataType: "json",
			data:{
				"schemeid":schemeid,
				"versionid":versionid,
				"resultid": resultid,
				"username": username
							},
			url: "../pv/listScheme/delListScheme" 
		}).done(function(res) {
			jyyMain.refreshTree();
			if(node.data.data.code == jyyMain.selectScheme){
				parent.setSelectScheme(null, null);
				jyyMain.selectScheme = null;
			}else{
				jyyMain.tree.checkNode(node.data.data.code,true);
			}
			JyyLoading.end();
		}).fail(function(res) {
			JyyLoading.end();
		});
	}
}
//删除二级方案
jyyMain.deleteListScheme2 = function(node) {
	//debugger
//var parentData = res.node.nodeli.data;
	var schemeid=node.data.nodeli.data.code;
	var versionid = node.data.data.code;
	var username = jyyMain.user.userName;
	

	if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
		JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
	}else{
		JyyLoading.start();
		$.ajax({
	   		async: false,
			dataType: "json",
			data:{
				"schemeid":schemeid,
				"versionid":versionid,
				"username": username
							},
			url: "../pv/listScheme/delListScheme2" 
		}).done(function(res) {
			jyyMain.refreshTree();
			if(node.data.data.code == jyyMain.selectScheme){
				parent.setSelectScheme(null, null);
				jyyMain.selectScheme = null;
			}else{
				jyyMain.tree.checkNode(node.data.data.code,true);
			}
			JyyLoading.end();
		}).fail(function(res) {
			JyyLoading.end();
		});
	}
}
//刷新方案数据
jyyMain.refreshTree = function() {
	if(jyyMain.tree){
	   	$.ajax({
	   		async: false,
			dataType: "json",
			data:{"addUser":jyyMain.user.userName},
			url: "../pv/main/getSchemeList"
		}).done(function(res) {
			var scheme = eval("("+res+")");
		//	console.log(res+"wwwwww"+11);
			jyyMain.scheme = scheme;
			jyyMain.tree.refreshData(scheme);
			jyyMain.tree.expandLevel(1);
		});
	}
}

//刷新三级方案数据
jyyMain.refreshTrees = function() {
	if(jyyMain.tree){
		//console.log(jyyMain.tree +"sssss"+1);
	   	$.ajax({
	   		async: false,
			dataType: "json",
			data:{
				"addUser":jyyMain.user.userName
				},
			url: "../pv/main/getSchemeList"
		}).done(function(res) {
			var scheme = eval("("+res+")");
			jyyMain.scheme = scheme;
			jyyMain.tree.refreshData(scheme);
			jyyMain.tree.expandLevel(4);
			
		
		});
	}
}

//设置三级方案
jyyMain.setListScheme = function(title,node){
	jyyMain.RightMenuData = node.data.data;
	window.modal = jyyModal.open("modal/addListScheme.html",{width:280, height:180, title:title}, function(){
		$("#addUser").val(jyyMain.user.userName);
			if(title != "新建方案"){
			$("#type").val("update");
			$("#schemeName").val(node.data.data.name);
			$("#resultId").val(node.data.data.code); 
			$("#DatFile").hide();
			$("#SwiFile").hide(); 
		}else{
			$("#type").val("add");
		}
		
		$("#cancelScheme").on("click", function(){
			window.modal.close();
		});
	});
};


//设置方案
jyyMain.setScheme = function(title,node){
	jyyMain.RightMenuData = node.data.data;
	window.modal = jyyModal.open("modal/addScheme.html",{width:280, height:260, title:title}, function(){
		$("#addUser").val(jyyMain.user.userName);
		if(title != "新建方案"){
			$("#type").val("update");
			$("#schemeName").val(node.data.data.name);
			$("#remark").val(node.data.data.remark);
			$("#schemeId").val(node.data.data.code);
			$("#DatFile").hide();
			$("#SwiFile").hide();
		}else{
			$("#type").val("add");
		}
		
		$("#cancelScheme").on("click", function(){
			window.modal.close();
		});
	});
};

//保存方案
jyyMain.submit = function() {
	var type = $("#type").val();
	
		if(type == "add"){
			$("#frmScheme").attr("action", "../pv/main/addScheme");
					}
		else{
			var newName = $("#schemeName").val();
			jyyMain.RightMenuData
			/*if(jyyMain.RightMenuData.name != null && jyyMain.RightMenuData.name == newName){
				JyyMsgBox.alert({ title:"提示", message:"方案名称修改成功",type:"warning"}).on(function (e) {});
				window.modal.close();
				return false;
			}else{
				$("#frmScheme").attr("action", "../pv/main/updScheme");
				$("#frmListScheme").attr("action", "../pv/listScheme/update");
			}*/
			$("#frmScheme").attr("action", "../pv/main/updScheme");
			$("#frmListScheme").attr("action", "../pv/listScheme/update");
		}
		$("#imgLoad").show();
		$("#frmScheme").ajaxSubmit({
			success : function(data) {
				JyyMsgBox.alert({ title:"提示", message:data.msg, type:"warning"}).on(function (e) {});
				if(data.flag == 1){
					$("#imgLoad").hide();
					return
				}
				jyyMain.refreshTree();
				$("#imgLoad").hide();
				window.modal.close();
			},
			error : function(data) {
				$("#imgLoad").hide();
				window.modal.close();
			}
		});
		$("#frmListScheme").ajaxSubmit({
			success : function(data) {
				JyyMsgBox.alert({ title:"提示", message:data.msg, type:"warning"}).on(function (e) {});
				if(data.flag == 1){
					$("#imgLoad").hide();
					return
				}
				jyyMain.refreshTrees();
				$("#imgLoad").hide();
				window.modal.close();
			},
			error : function(data) {
				$("#imgLoad").hide();
				window.modal.close();
			}
		});
		return false;
}
//删除方案
jyyMain.deleteScheme = function(node) {
    var schemeid=node.data.data.code;
    var versionid=node.data.nodeli.data.code;
	var username = jyyMain.user.userName;
	
	if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
		JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
	}else{
		JyyLoading.start();
		$.ajax({
	   		async: true,
			dataType: "json",
			data:{
				"schemeid":schemeid,
				"versionid":versionid,
				"username": username
				},
			url: "../pv/main/delScheme"
		}).done(function(res) {
			jyyMain.refreshTree();
			if(node.data.data.code == jyyMain.selectScheme){
				parent.setSelectScheme(null, null);
				jyyMain.selectScheme = null;
			}else{
				jyyMain.tree.checkNode(node.data.data.code,true);
			}
			JyyLoading.end();
		}).fail(function(res) {
			JyyLoading.end();
		});
	}
}


//获取用户列表
jyyMain.getUserList = function(){
	var user = null;
	$.ajax({
   		async: false,
		dataType: "json",
		data:{"addUser":jyyMain.user.userName},
		url : "../pv/main/getUserList/" + jyyMain.user.userName
	}).done(function(res) {
		user = eval("("+res+")");
	});
	var userList={
		data:user,
		isShowCheckBox:true,
		isShowFun:false
	};
	return userList;
}
//获取方案共享用户
jyyMain.getShareUser = function(){
	var shareUser=null;
	var code=parent.getSelectScheme().code;
	$.ajax({
   		async: false,
		dataType: "json",
		data:{"addUser":jyyMain.user.userName},
		url: "../pv/main/getMainSchemeShare/"+code
	}).done(function(res) {
		shareUser = eval("("+res+")");
	});
	var userMap = {};
	for (var i = 0; i < shareUser.length; i++) {
		userMap[shareUser[i]] = shareUser[i];
	}
	return userMap;
}
//添加授权用户
jyyMain.addShare = function(){
	window.modal = jyyModal.open(null,{width:300, height:300, title:"添加授权用户"}, function(){});
		$("#modal").html('<div id="table"></div><div class="modal-footer" style="margin-top: 195px;"><button type="submit" id="saveShare" class="btn btn-primary btn-sm" ACCESSKEY="s"  data-dismiss="smodal">确&nbsp;定&nbsp;</button><button type="button" id="cancelShare" class="btn btn-default btn-sm" data-dismiss="modal">取&nbsp;消</button></div>');
		
		var userList = jyyMain.getUserList();
		var userMap = jyyMain.getShareUser();
		
		var table = JyyTable.init("table", userList, {position:"absolute",top:"5px",left:"5px",right:"5px",bottom:"60px",overflow:"hidden"}, function(){});
		//回显授权用户
		$(table).find('table tbody tr').each(function () {
			var code = $(this).find('td:eq(1)').attr("code");
			if(userMap[code]){
				$(this).find('input').click();
			}
		});
		$("#cancelShare").click(function(){window.modal.close();});
		$("#saveShare").click(function(){
			var data = [];
			var rows = $(table).find('table tbody tr input[type=checkbox]:checked').parents('tr').each(function () {
				data[data.length] = this;
			});
			var value = JyyTable.ctrl.getValue(data, true, true);
			var userName = "";
			for (var i = 1; i < value.length; i++) {
				userName += value[i][0];
				if(i < value.length - 1){
					userName += ",";
				}
			}
			$.ajax({
				async: true,
				dataType: "json",
				data:{schemeid:parent.getSelectScheme().code,userName:userName},
				url: "../pv/main/addSchemeShare" 
			}).done(function(res) {
				window.modal.close();
			}).fail(function(res) {
				window.modal.close();
			});
		});
	
}
//清除授权用户
jyyMain.clearShare = function(){
	JyyMsgBox.confirm({ title:"提示", message:"确定清除授权用户？",type:"warning"}).on(function (e) {
		if (e) {
			$.ajax({
				async: true,
				dataType: "json",
				url: "../pv/main/delUser/" + parent.getSelectScheme().code
			});
		}
	});
}
/** ------------------------------方案列表-end-----------------------------------**/
//模块点击事件
jyyMain.onMainClick = function(e){
	var name = $(this).attr("name");
	if(name == "dataImport" || name == "dataEdit" || name == "dataAnalys" || name == "DatImport"){
		if(name == "dataImport"){//运行模拟数据导入
			
			/*if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
				JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
			}else{
				$("#userName").val(parent.user.userName);
				$("#schemeid").val(parent.getSelectScheme().code);
				$("#parentCode").val("dataImport");
				$("#uploadAll").click();
			}*/
			
			var exeMenu = JyyMenu.IMP_MENU;
			var jyymenu = new JyyMenu(exeMenu, jyyMain.onExeMenuClick);
			jyymenu.show({event:e, data:{code:name, name:this.innerText}});
			
			
		}else if(name == "dataEdit"){//运行模拟数据维护
			if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
				JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
			}else{
				parent.addTab({id:name, name:this.innerText, url:"dataSource.html", closable:true, active:true});
			}
		}else if(name == "dataAnalys"){//数据分析
			window.parent.location.href="pages/main.html?mapFlag=1";
			sessionStorage.setItem("framsDis", 'none'); 
		}else if(name == "DatImport"){//BPA数据导入
			if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
				JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
			}else{
				window.modal = jyyModal.open("modal/datImport.html",{width:280,height:290,title:this.innerText},function(){
					$("#schemeName").val(parent.getSelectScheme().name);
					$("#cancelScheme").on("click", function(){window.modal.close();});
					$("#frmScheme").attr("action","../pv/main/datImport");
					$("#frmListScheme").attr("action","../pv/main/datImport");
					$("#frmBpaScheme").attr("action","../pv/main/datImport");
					$("#saveScheme").on("click",function(){
						if($("#SWIData").val()==''||$("#DATData").val()==''){
							JyyMsgBox.alert({ title:"警告", message:"请上传文件!",type:"info"}).on(function (e) {});
							
						}else{
							JyyLoading.start();
							var schemeid = parent.getSelectScheme().code;
							var schemeName = parent.getSelectScheme().name;
							$("#schemeidxx").val(schemeid);
							$("#schemeNamexx").val(schemeName);
							$("#addUser").val(parent.user.userName);
							$("#frmScheme").ajaxSubmit({
								success:function(data){
									JyyLoading.end();
									JyyMsgBox.alert({ title:"提示", message:"数据导入成功!",type:"info"}).on(function (e) {});
								}
							});
							$("#frmListScheme").ajaxSubmit({
								success:function(data){
									JyyLoading.end();
									JyyMsgBox.alert({ title:"提示", message:"数据导入成功!",type:"info"}).on(function (e) {});
								}
							});
							$("#frmBpaScheme").ajaxSubmit({
								success:function(data){
									JyyLoading.end();
									JyyMsgBox.alert({ title:"提示", message:"数据导入成功!",type:"info"}).on(function (e) {});
								}
							});
							window.modal.close();
						}
					});
				});
			}
		}
	}else if(name == "dataConvert"){//运行模拟数据转换
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			window.modal = jyyModal.open("modal/converExcel.html", {width:450, height:240, title:this.innerText}, function(){
				$("#convertForm").attr("action", "../pv/convertExcel/convert");
				$('#divBpaFile > label').html('<span class="text-danger">*</span>潮流文件->运行模拟数据');
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").text("数 据 转 换");
				$("#divSwiFile").remove();
				$("#divVoltValue").show();
				$("#convertExcel").on("click", function(){
					//var isTrue = jyyMain.checkDatFile(false);
					var isTrue = true;
					if(isTrue){
						$("#convertForm").submit();
						window.modal.close();
					}
				});
			});
		}
	} else if(name == "wpOutput" || name == "pvOutput" || name == "planning2" || name == "dataNet"){//风电出力重构、光伏出力重构、柔性优化规划、网架规划
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			if(!parent.getSelectScheme()){
				JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
				return;
			}
			
			var exeMenu = JyyMenu.EXE_MENU;
			if(name == "wpOutput" || name == "pvOutput"){
				exeMenu.menus[0].isHide = true;
				exeMenu.menus[1].isHide = true;
				exeMenu.menus[2].isHide = false;
				exeMenu.menus[3].isHide = false;
				exeMenu.menus[4].isHide = true;
				exeMenu.menus[5].isHide = true;
				exeMenu.menus[6].isHide = true;
				exeMenu.menus[7].isHide = true;
				exeMenu.menus[8].isHide = true;
			}else if(name == "planning2"){
				exeMenu.menus[0].isHide = true;
				exeMenu.menus[1].isHide = false;
				exeMenu.menus[2].isHide = false;
				exeMenu.menus[3].isHide = false;
				exeMenu.menus[4].isHide = true;
				exeMenu.menus[5].isHide = true;
				exeMenu.menus[6].isHide = true;
				exeMenu.menus[7].isHide = true;
				exeMenu.menus[8].isHide = true;
			}else{
				exeMenu.menus[0].isHide = true;
				exeMenu.menus[1].isHide = true;
				exeMenu.menus[2].isHide = true;
				exeMenu.menus[3].isHide = true;
				exeMenu.menus[4].isHide = true;
				exeMenu.menus[5].isHide = false;
				exeMenu.menus[6].isHide = false;
				exeMenu.menus[7].isHide = false;
				exeMenu.menus[8].isHide = true;
			}
			var jyymenu = new JyyMenu(exeMenu, jyyMain.onExeMenuClick);
			jyymenu.show({event:e, data:{code:name, name:this.innerText}});
		}
	}else if(name == "exeDsedH"){ 
		parent.onModelClick();
		sessionStorage.setItem("framsDis", 'block'); 
		window.parent.location.href="pages/main.html";
	} else if(name == "powerBalance"){
		//电力平衡分析、电量平衡分析、机组利用分析、可再生能源消纳分析、线路断面分析、系统工作位置图
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			if(!parent.getSelectScheme()){
				JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
				return;
			}
			var url = jyyMain.getUrl(name);
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:name, name:"电力平衡分析", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"电力平衡分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}
	}else if(name == "cellBalance"){
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			if(!parent.getSelectScheme()){
				JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
				return;
			}
			var url = jyyMain.getUrl(name);
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:name, name:"电量平衡分析", url:url + "&projectid=" + code, closable:true, active:true});
		/*	window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"电量平衡分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}
	
	}else if(name == "unitUtilizationAnalys"){
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			if(!parent.getSelectScheme()){
				JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
				return;
			}
			var url = jyyMain.getUrl(name);
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){*/
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"机组利用分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
			/*	});
			});*/
		}
	
	}else if(name == "renewableEnergyAnalys"){
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			if(!parent.getSelectScheme()){
				JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
				return;
			}
			var url = jyyMain.getUrl(name);
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:name, name:"可再生能源消纳分析", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"可再生能源消纳分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}
	
	}else if(name == "lineSectionAnalys"){
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			if(!parent.getSelectScheme()){
				JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
				return;
			}
			var url = jyyMain.getUrl(name);
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:name, name:"线路断面分析", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"线路断面分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}
	
	}else if(name == "systemPositionMap"){
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			if(!parent.getSelectScheme()){
				JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
				return;
			}
			var url = jyyMain.getUrl(name);
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:name, name:"系统工作位置图", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"系统工作位置图", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}
	
	} else if(name == "ACflowgeneration"){//潮流文件生成
		/*$("#ccc").show();
		$('.DivClose,.canelBtn').click(function(){
			$("#ccc").hide();
		});
		$.ajax({
			url: "g/service/Sample/getCompDatas",
			type:'POST',
			cache:false,
			async:true,
			dataType: "json",
			data: JSON.stringify({userId:userId,modelId:'0'}),
			contentType:"application/json",
	        success:function(data){
				var content = '';
				$("#simulaScheme").empty();
				$.each(data.compData,function(i,n){
					if(i == 0 || (i!=0 && n.projectId!=data.compData[i-1].projectId)) {
						if(i!=0){
							content += "</optgroup>";
						}
						content += "<optgroup label='" + n.projectName + "'>";
					}
					content += "<option value='" + n.planCode + "'>"+ n.planName+"</option>";
				});
				$("#simulaScheme").append(content+"</optgroup>");
				$("#simulaScheme").selectpicker('refresh');
			}
		});
		var option = "";
		for(var i = 1;i <= 24;i++) {
			option += "<option value='"+i+"'>"+i+"</option>";
		}
		for(var i = 0;i < 5;i++) {
			$('#date'+i).datetimepicker({
		        format:"mm-dd",minView:2,maxView:3,startView:2,autoclose:1,language: 'cn',pickerPosition:'top-right'
		    });
			$("#time"+i).append(option);
			$("#time"+i).selectpicker('refresh');
		}
		$('.doBtn').click(function(){
			var simulaScheme = $('#simulaScheme').val();
			if(simulaScheme == "") {
				alert("请选择方案")
				return;
			}
			var fileInput = $('#dat').get(0).files[0];
			if(fileInput == undefined) {
				alert("请选择文件")
				return;
			}
			var suffix = fileInput==null?"":fileInput.name.substring(fileInput.name.lastIndexOf(".")+1, fileInput.name.length);
			if(suffix.toUpperCase() != "DAT") {
				alert("请选择dat文件")
				return;
			}
			var boxs = [];
			$('input[name="time"]:checked').each(function(){
				boxs.push($(this).val());
			});
			if(boxs.length == 0) {
				alert("请选中至少一组时刻")
				return;
			}
			var dates = [];
			var times = [];
			for(var i = 0;i < boxs.length;i++) {
				if($("#date"+boxs[i]).find("input").val()=="") {
					alert("日期不能为空")
					return;
				}
				dates.push($("#date"+boxs[i]).find("input").val());
				times.push($('#time'+boxs[i]).val());
			}
			JyyLoading.start({"topHtml":0});
	        let formDateObj = new FormData();
	        // 2 添加普通的键值对
	        formDateObj.append('projectId', simulaScheme);
	        formDateObj.append('boxs', boxs);
	        formDateObj.append('dates', dates);
	        formDateObj.append('times', times);
	        // 3 添加文件对象
	        formDateObj.append('file', fileInput);
			$.ajax({
				type:"POST",
			 	url:"g/service/Sample/impDatToOracle",
				cache:false,
				async:true,
				data: formDateObj,
				contentType:false,
				processData:false,
				success:function(data){
					$("#zipName").val(data);
					$("#bpaZipForm").submit();
					JyyLoading.end();
				}
			});
		});*/
		window.location.href="pages/compares.html";
	}else if(name == "Psdedit" ){
		
		if(!jyyMain.selectScheme){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}
		var exeMenu = JyyMenu.EXE_MENUPSD;
			exeMenu.menus[0].isHide = false;
			exeMenu.menus[1].isHide = false;
			exeMenu.menus[2].isHide = false;
			exeMenu.menus[3].isHide = false;
		var jyymenu = new JyyMenu(exeMenu, jyyMain.onExeMenuClick);
		jyymenu.show({event:e, data:{code:name, name:this.innerText}});
	}else if(name == "flowParamCheck"){
		//window.location.href="pages/compares.html";
	}else if(name == "flowConvergenceTrim" || name == "flowResultAnalys" || 
			name == "staticSecurityAnalys" || name == "StableParamCheck" || name == "batchCalculate"){
		//潮流参数校验、潮流收敛调整、潮流结果分析、静态安全分析、稳定参数校验、批量稳定计算
		if(!jyyMain.selectScheme){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}
		var exeMenu = JyyMenu.EXE_MENU;
		if(name == "flowResultAnalys"){
			exeMenu.menus[0].isHide = true;
			exeMenu.menus[1].isHide = true;
			exeMenu.menus[2].isHide = false;
			exeMenu.menus[3].isHide = false;
			exeMenu.menus[4].isHide = false;
			exeMenu.menus[5].isHide = true;
			exeMenu.menus[6].isHide = true;
			exeMenu.menus[7].isHide = true;
			exeMenu.menus[8].isHide = false;
		}else{
			exeMenu.menus[0].isHide = true;
			exeMenu.menus[1].isHide = true;
			exeMenu.menus[2].isHide = false;
			exeMenu.menus[3].isHide = false;
			exeMenu.menus[4].isHide = true;
			exeMenu.menus[5].isHide = true;
			exeMenu.menus[6].isHide = true;
			exeMenu.menus[7].isHide = true;
			exeMenu.menus[8].isHide = false;
		}
		var jyymenu = new JyyMenu(exeMenu, jyyMain.onExeMenuClick);
		jyymenu.show({event:e, data:{code:name, name:this.innerText}});
	}else if(name == "selectionPlan"){
		window.location.href="pages/comparisonScheme.html?modelId=0";
	}else if(name == "safetyEvaluation"){
		if(parent.getSelectScheme() == null){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}
		parent.setEvaluationName("safetyEvaluation");
		parent.addTab({id:"safetyEvaluation1", name:"安全性指标_指标数据", url:"evaluationIndexData.html?tabType=safetyEvaluation", closable:true, active:true});
		parent.addTab({id:"safetyEvaluation2", name:"安全性指标_指标赋权", url:"evaluationIndexWeighting.html?tabType=safetyEvaluation", closable:true});
		parent.addTab({id:"safetyEvaluation3", name:"安全性指标_指标评价", url:"evaluationIndexEvaluation.html?tabType=safetyEvaluation", closable:true});
	}else if(name == "economicEvaluation"){
		if(parent.getSelectScheme() == null){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}
		parent.setEvaluationName("economicEvaluation");
		parent.addTab({id:"economicEvaluation1", name:"经济性指标_指标数据", url:"evaluationIndexData.html?tabType=economicEvaluation", closable:true, active:true});
		parent.addTab({id:"economicEvaluation2", name:"经济性指标_指标赋权", url:"evaluationIndexWeighting.html?tabType=economicEvaluation", closable:true, active:true});
		parent.addTab({id:"economicEvaluation3", name:"经济性指标_指标评价", url:"evaluationIndexEvaluation.html?tabType=economicEvaluation", closable:true, active:true});
	}else if(name == "environmentalEvaluation"){
		if(parent.getSelectScheme() == null){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}
		parent.setEvaluationName("environmentalEvaluation");
		parent.addTab({id:"environmentalEvaluation1", name:"环保性指标_指标数据", url:"evaluationIndexData.html?tabType=environmentalEvaluation", closable:true, active:true});
		parent.addTab({id:"environmentalEvaluation2", name:"环保性指标_指标赋权", url:"evaluationIndexWeighting.html?tabType=environmentalEvaluation", closable:true, active:true});
		parent.addTab({id:"environmentalEvaluation3", name:"环保性指标_指标评价", url:"evaluationIndexEvaluation.html?tabType=environmentalEvaluation", closable:true, active:true});
	}else if(name == "flexibilityEvaluation"){
		if(parent.getSelectScheme() == null){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}
		parent.setEvaluationName("flexibilityEvaluation");
		parent.addTab({id:"flexibilityEvaluation1", name:"灵活性指标_指标数据", url:"evaluationIndexData.html?tabType=flexibilityEvaluation", closable:true, active:true});
		parent.addTab({id:"flexibilityEvaluation2", name:"灵活性指标_指标赋权", url:"evaluationIndexWeighting.html?tabType=flexibilityEvaluation", closable:true, active:true});
		parent.addTab({id:"flexibilityEvaluation3", name:"灵活性指标_指标评价", url:"evaluationIndexEvaluation.html?tabType=flexibilityEvaluation", closable:true, active:true});
	}else if(name == "comprehensiveEvaluation"){
		if(parent.getSelectScheme() == null){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}
		parent.setEvaluationName("comprehensiveEvaluation");
		parent.addTab({id:"comprehensiveEvaluation1", name:"综合评价_指标权重", url:"evaluationIndexWeighting.html?tabType=comprehensiveEvaluation", closable:true, active:true});
		parent.addTab({id:"comprehensiveEvaluation2", name:"综合评价_综合评价", url:"evaluationIndexEvaluation.html?tabType=comprehensiveEvaluation", closable:true});
		parent.addTab({id:"comprehensiveEvaluation3", name:"综合评价_对比分析", url:"evaluationComparativeAnalysis.html?tabType=comprehensiveEvaluation", closable:true});
	}else if(name == "GoCalculationForE" || name == "GoCalculationForR"){
		if(!parent.getSelectScheme()){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}else{
			$.ajax({
				type:"POST",
			 	url:"../pv/executive/exeForPlatform",
			 	data:{"type_1":"fsdxtkkx"}//发输电系统可靠性
			});
		}
	}else if(name == "ResultForE"){
		url = jyyMain.getUrl(name);
		parent.addTab({id:name, name:"机电——电磁暂态混合仿真", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
	}else if(name == "ResultForR"){
		url = jyyMain.getUrl(name);
		parent.addTab({id:name, name:"电网分析评估", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
	}else if(name == "jjcs"){
		var exeMenu = JyyMenu.EXE_MENU;
		exeMenu.menus[0].isHide = false;
		exeMenu.menus[1].isHide = true;
		exeMenu.menus[2].isHide = false;
		exeMenu.menus[3].isHide = false;
		exeMenu.menus[4].isHide = true;
		exeMenu.menus[5].isHide = true;
		exeMenu.menus[6].isHide = true;
		exeMenu.menus[7].isHide = true;
		exeMenu.menus[8].isHide = true;
		var jyymenu = new JyyMenu(exeMenu, jyyMain.onExeMenuClick);
		jyymenu.show({event:e, data:{code:name, name:this.innerText}});
	}else if(name == "tzcs"){
		var exeMenu = JyyMenu.EXE_MENU;
		exeMenu.menus[0].isHide = false;
		exeMenu.menus[1].isHide = true;
		exeMenu.menus[2].isHide = false;
		exeMenu.menus[3].isHide = false;
		exeMenu.menus[4].isHide = true;
		exeMenu.menus[5].isHide = true;
		exeMenu.menus[6].isHide = true;
		exeMenu.menus[7].isHide = true;
		exeMenu.menus[8].isHide = true;
		var jyymenu = new JyyMenu(exeMenu, jyyMain.onExeMenuClick);
		jyymenu.show({event:e, data:{code:name, name:this.innerText}});
	}else if(name == "sdjcs"){
		$.ajax({
			type:"POST",
		 	url:"../pv/executive/exeForPlatform",
		 	data:{"type_1":"sdjcs"}
		});
	}else if(name == "tzxq"){
		var exeMenu = JyyMenu.EXE_MENU;
		exeMenu.menus[0].isHide = false;
		exeMenu.menus[1].isHide = true;
		exeMenu.menus[2].isHide = false;
		exeMenu.menus[3].isHide = false;
		exeMenu.menus[4].isHide = true;
		exeMenu.menus[5].isHide = true;
		exeMenu.menus[6].isHide = true;
		exeMenu.menus[7].isHide = true;
		exeMenu.menus[8].isHide = true;
		var jyymenu = new JyyMenu(exeMenu, jyyMain.onExeMenuClick);
		jyymenu.show({event:e, data:{code:name, name:this.innerText}});
	}else if(name == "tznl"){
		var exeMenu = JyyMenu.EXE_MENU;
		exeMenu.menus[0].isHide = false;
		exeMenu.menus[1].isHide = true;
		exeMenu.menus[2].isHide = false;
		exeMenu.menus[3].isHide = false;
		exeMenu.menus[4].isHide = true;
		exeMenu.menus[5].isHide = true;
		exeMenu.menus[6].isHide = true;
		exeMenu.menus[7].isHide = true;
		exeMenu.menus[8].isHide = true;
		var jyymenu = new JyyMenu(exeMenu, jyyMain.onExeMenuClick);
		jyymenu.show({event:e, data:{code:name, name:this.innerText}});
	}else if(name == "pscad"){
		$.ajax({
			type:"POST",
		 	url:"../pv/executive/exeForPlatform",
		 	data:{"type_1":"pscad"}
		});
	}else if(name == "netomac"){
		$.ajax({
			type:"POST",
		 	url:"../pv/executive/exeForPlatform",
		 	data:{"type_1":"netomac"}
		});
	}else if(name == "sper"){
		$.ajax({
			url:"../pv/executive/exeForPlatform",
			type:"POST",
			data:{"type_1":"sper","type_2":"sper"},
			success:function(res){
				console.log(res);
			}
		});
	}else if(name == "G2LvPalan"){//2级规划方案生成
		if(!parent.getSelectScheme()){
			JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
			return;
		}else{
			
			window.modal = jyyModal.open("modal/btnRemainPage.html",{width:500, height:315, title:"级规划方案生成"},function(){
				$("#cancelScheme").on("click",function(){window.modal.close();});
				$("#saveScheme").on("click",function(){
					
					$("#schemeId").val(parent.getSelectScheme().code);
					if($("#selectSchemeName option:selected").length == 0 && $("#selectSchemeName option").length != 0){
						JyyMsgBox.alert({ title:"提示", message:"请选择新建版本",type:"info"}).on(function (e) {});
						return;
					}else{
						if($("#selectSchemeName option").length != 0){
							$("#oldId").val($("#selectSchemeName option:selected")[0]["value"]);
						}else{
							$("#oldId").val(parent.getSelectScheme().code);
						}
						$("#remainForm").ajaxSubmit({
							success:function(data){
								console.log(data);
								window.modal.close();
								jyyMain.refreshTree();
								if(data.flag == 0){
									JyyMsgBox.alert({ title:"提示", message:"规划方案另存成功",type:"info"}).on(function (e) {});
									jyy.versionid = data.result.versionId;
									jyy.schemeName = data.result.schemeName;
								}else{
									JyyMsgBox.alert({ title:"提示", message:"规划方案另存失败",type:"info"}).on(function (e) {});
								}
								init();
								parent.refreshTreeAll();
								$("#selectName").val(jyy.versionid);
								jyy.self = 0;
								jyy.query();
								action.do(this.id);
							}
						});
						
					}
					
				});
			});
		}
	}else if(name == "GdataImport"){//外部bpa数据接入
		if(!parent.getSelectScheme2()){
			JyyMsgBox.alert({ title:"提示", message:"请选择2级方案!",type:"info"}).on(function (e) {});
			return;
		}else{
			if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
				JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
			}else{
				window.modal = jyyModal.open("modal/datImport.html",{width:280,height:290,title:this.innerText},function(){
					$("#schemeName").val(parent.getSelectScheme2().name);
					$("#cancelScheme").on("click", function(){window.modal.close();});
					$("#frmScheme").attr("action","../pv/main/datImport2Lev");
					$("#saveScheme").on("click",function(){
						if($("#SWIData").val()==''||$("#DATData").val()==''){
							JyyMsgBox.alert({ title:"警告", message:"请上传文件!",type:"info"}).on(function (e) {});
							
						}else{
							JyyLoading.start();
							var Pschemeid = parent.getSelectScheme().code;
							var schemeid = parent.getSelectScheme2().code;
							var schemeName = parent.getSelectScheme2().name;
							$("#pschemeidxx").val(Pschemeid);
							$("#schemeidxx").val(schemeid);
							$("#schemeNamexx").val(schemeName);
							$("#addUser").val(parent.user.userName);
							$("#frmScheme").ajaxSubmit({
								success:function(data){
									JyyLoading.end();
									JyyMsgBox.alert({ title:"提示", message:"数据导入成功!",type:"info"}).on(function (e) {});
								}
							});
							$("#frmListScheme").ajaxSubmit({
								success:function(data){
									JyyLoading.end();
									JyyMsgBox.alert({ title:"提示", message:"数据导入成功!",type:"info"}).on(function (e) {});
								}
							});
							$("#frmBpaScheme").ajaxSubmit({
								success:function(data){
									JyyLoading.end();
									JyyMsgBox.alert({ title:"提示", message:"数据导入成功!",type:"info"}).on(function (e) {});
								}
							});
							window.modal.close();
						}
					});
				});
			}
		}
	}else if(name == "GnewtWork"){//地理接线图
		var schemeid = parent.getSelectScheme().code;
		//var schemeid = parent.getSelectScheme2().code;
		
		parent.setParentPageName("planSchemeGeneration");
		parent.addTab({id:schemeid + "_network", name:"方案生成", url:"network.html?type=fasc", closable:true, active:true});
	}else if(name == "Gexcl"){//外部运行模拟数据接入
		if(!parent.getSelectScheme2()){
			JyyMsgBox.alert({ title:"提示", message:"请选择2级方案!",type:"info"}).on(function (e) {});
			return;
		}else{
			if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
				JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
			}else{
				$("#userName").val(parent.user.userName);
				$("#schemeid").val(parent.getSelectScheme().code);
				$("#bpaSchemeid").val(parent.getSelectScheme2().code);
				$("#parentCode").val("planSchemeLinked");
				$("#uploadAll").click();
			}
		}
	}
	
}
//菜单点击事件
jyyMain.onExeMenuClick = function(res, data){
	console.log(res);
	if(res.id == "exeBpa"){
		var code = data.data.code;
		if(code == "wpOutput" || code == "pvOutput"){
			var modalUrl = "modal/goptWpRun.html";
			var modalTitle = "风电出力重构参数";
			var modalWidth = 740;
			var modalHeight = 490;
			var type = "wpos";
			if(code == "pvOutput"){
				modalUrl = "modal/goptPvRun.html";
				modalTitle = "光伏出力重构参数";
				modalWidth = 540;
				modalHeight = 455;
				type = "pvos";
			}
			window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.setSelectBpaSchemeCode(code);
					window.modal.close();
					var exists = jyyMain.isExistsGoptData(code);
					if(exists){
						window.modal = jyyModal.open(modalUrl, {width:modalWidth, height:modalHeight, title:modalTitle}, function(){
							jyyMain.intervalObj = setInterval(jyyMain.isOk, 0.1 * 1000);
							
							$("#closeParams").on("click", function(){window.modal.close();});
							$("#saveParams").on("click", function(){
								var params = getParams();
								jyyMain.setParames(params, {type:type, name:code});
								window.modal.close();
							});
						});
					}else{
						JyyMsgBox.alert({ title:"提示", message:"请导入数据!",type:"info"}).on(function (e) {});
						return;
					}
				});
			});
		}else{
			if(data.data.code == "planning2"){//柔性优化规划
				if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
					JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
				}else{
					if(!parent.getSelectScheme()){
						JyyMsgBox.alert({ title:"提示", message:"请选择方案!",type:"info"}).on(function (e) {});
						return;
					}
					var exists = true;
					if(exists){
						window.modal = jyyModal.open("modal/goptParams.html",{width:786, height:450, title:"柔性优化规划"}, function(){
							//获取精细生产运行模拟参数
							var params = jyyMain.getParamesForPlan();
							$("#saveParams").text("柔  性  规  划");
							//初始化页签信息
							var item = [
								{'id':'tsepBase','name':'基本参数','url':'modal/tsepBase.html','closable':false,active:true},
								{'id':'tsepPlan','name':'规划选项','url':'modal/tsepPlan.html','closable':false},
								{'id':'tsepOpc','name':'运行约束选项','url':'modal/tsepOpc.html','closable':false},
								{'id':'tsepSen','name':'灵敏度选项','url':'modal/tsepSen.html','closable':false},
								{'id':'tsepCal','name':'计算选项','url':'modal/tsepCal.html','closable':false}
								];
							var tab = JyyTab.init("jyyParamstab", item, {isCheck:true}, {position:"absolute",top:"0px",left:"0px",right:"0px",bottom:"0px"},function(res){
								if(res.name == "init"){
									for(key in res.ifarme){
										res.ifarme[key].contentWindow.setParams(params);
									}
								} else if(res.name == "check"){
									var info = res.ifarme.contentWindow.check();
									$("#info").text(info);
									return info == "" ? true : false;
								}
							});
							$("#closeParams").on("click", function(){window.modal.close();});
							
							$("#saveParams").on("click", function(){
								JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
								var defaults = {};
								for(key in tab.ifarmeMap){
									var params = tab.ifarmeMap[key].contentWindow.getParams();
									$.extend(defaults, params);
								}
								$.ajax({
									url:"../pv/scheme/saveScheme",
									type:"POST",
									async:false,
									data:{oldId:parent.getSelectScheme().code,schemeId:parent.getSelectScheme().code,schemeName:defaults.newPlanName,centerLat:defaults.centerLat,centerLng:defaults.centerLng,defaultZoom:defaults.defaultZoom,maxZoom:defaults.maxZoom,minZoom:defaults.minZoom,parentId:defaults.parentId,type:defaults.type},
									success:function(data){
										parent.setBpaResultCode(data.result.versionId);
										jyyMain.refreshTree();
									}
								});
								jyyMain.setParames(defaults,{type:"tsep",name:"tsep"});
								window.modal.close();
							});
							
							$("#saveListScheme").on("click", function(){
								JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
								var defaults = {};
								for(key in tab.ifarmeMap){
									var params = tab.ifarmeMap[key].contentWindow.getParams();
									$.extend(defaults, params);
								}
								$.ajax({
									url:"../pv/listScheme/update",
									type:"POST",
									async:false,
									data:{oldId:parent.getSelectScheme().code,schemeId:parent.getSelectScheme().code,defaultZoom:defaults.defaultZoom,maxZoom:defaults.maxZoom,minZoom:defaults.minZoom,parentId:defaults.parentId,type:defaults.type},
									success:function(data){
										parent.setBpaResultCode(data.result.versionId);
										jyyMain.refreshTree();
									}
								});
								jyyMain.setParames(defaults,{type:"tsep",name:"tsep"});
								window.modal.close();
							});
							
						});
						
					}else{
						JyyMsgBox.alert({ title:"提示", message:"请导入数据!",type:"info"}).on(function (e) {});
						return;
					}
				}
		}else if(data.data.code == "flowParamCheck"){
				window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:"潮流参数校验"}, function(){
					$("#convertForm").attr("action", "../pv/executive/uploadDatFile");
					$("#cancelScheme").on("click", function(){window.modal.close();});
					$("#saveScheme").on("click", function(){
						//var isTrue = jyyMain.checkDatFile(true);
						var isTrue = true;
						if(isTrue){
//							fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length);
							$("#type_1").val("E1");
							$("#type_2").val(data.data.code);
							$("#versionidForExe").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
							$("#projectidForExe").val(parent.getSelectScheme().code);
							$("#bpaResultid").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
							$("#userNameForExe").val(parent.user.userName);
							parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
							JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
							$("#convertForm").ajaxSubmit({
								success : function(res) {
									JyyLoading.end();
								}
							});
							window.modal.close();
						}
					});
				});
			} else if(data.data.code == "flowConvergenceTrim"){
				window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:"潮流收敛调整"}, function(){
					$("#convertForm").attr("action", "../pv/executive/uploadDatFile");
					$("#cancelScheme").on("click", function(){window.modal.close();});
					$("#saveScheme").on("click", function(){
						//var isTrue = jyyMain.checkDatFile(true);
						var isTrue = true;
						if(isTrue){
							$("#type_1").val("E1");
							$("#type_2").val(data.data.code);
							$("#versionidForExe").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
							$("#projectidForExe").val(parent.getSelectScheme().code);
							$("#bpaResultid").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
							$("#userNameForExe").val(parent.user.userName);
							parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
							JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
							$("#convertForm").ajaxSubmit({
								success : function(res){
									$("#bpaFlowForm").submit();
									JyyLoading.end();
								}
							});
							window.modal.close();
						}
					});
				});
			} else if(data.data.code == "flowResultAnalys"){
				window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:"潮流结果分析"},function(){
					$("#convertForm").attr("action", "../pv/executive/uploadDatFile");
					$("#cancelScheme").on("click", function(){window.modal.close();});
					$("#saveScheme").on("click", function(){
						//var isTrue = jyyMain.checkDatFile(true);
						var isTrue = true;
						if(isTrue){
							$("#type_1").val("E1");
							$("#type_2").val(data.data.code);
							$("#versionidForExe").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
							$("#projectidForExe").val(parent.getSelectScheme().code);
							$("#userNameForExe").val(parent.user.userName);
							$("#bpaResultid").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
							parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
							JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
							$("#convertForm").ajaxSubmit({
								success : function(res) {
									JyyLoading.end();
								}
							});
							window.modal.close();
						}
					});
				});
			} else if(data.data.code == "staticSecurityAnalys"){
					window.modal = jyyModal.open("modal/bpaSafetyAnaly.html",{width:1200, height:380, title:data.data.name}, function(){
						// 保存当前窗口的id
						var id = window.modal.id;
						$("#divBpaFile").remove();
						$("#closeParams").on("click", function(){
							// 设置当前窗口的id
							window.modal = window.modal.mapModal[id];
							window.modal.close();
						});
						$("#saveParamsForSafe").on("click", function(){
							var fileName = $("#bpaFile").val();
							fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length);
							$("#fileName").val(fileName);
							// 设置当前窗口的id
							window.modal = window.modal.mapModal[id];
							
							jyyMain.intervalObj = setInterval('jyyMain.exeBpaParams("staticSecurityAnalysIn")', 0.1 * 1000);
						});
					});
					
			}else if(data.data.code == "StableParamCheck"){//稳定参数校验
				window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205,title:data.data.name},function(){
					$("#cancelScheme").on("click",function(){window.modal.close();});
					$("#saveScheme").on("click",function(){
						parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
						parent.setSelectBpaSchemeCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
						JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
						jyyMain.expBpa("StableParamCheck");
					})
				});
			} else if(data.data.code == "batchCalculate"){
					window.modal = jyyModal.open("modal/bpaBatch.html",{width:1200, height:460, title:data.data.name}, function(){
						var id = window.modal.id;
						$("#divBpaFile").remove();
						$("#divSwiFile").remove();
						
						$("#closeParams").on("click", function(){
							// 设置当前窗口的id
							window.modal = window.modal.mapModal[id];
							window.modal.close();
						});
						$("#saveParamsForSafe").on("click", function(){
							window.modal = window.modal.mapModal[id];
							jyyMain.intervalObj = setInterval('jyyMain.exeBpaParams("batchCalculateIn")', 0.1 * 1000);
						});
					});
			}else if(data.data.code == "primitiveTarget"){
				JyyLoading.start();
				var selectScheme = parent.getSelectScheme();
				$.ajax({
					type:"POST",
				 	url:"../pv/appraise/call",
				 	data:{projectId:selectScheme.code},
					success:function(data){
						JyyLoading.end();
						JyyMsgBox.alert({ title:"提示", message:data.msg, type:"info"}).on(function (e) {});
					}
				});
			}else if(data.data.code == "tzxq"){
				var str = parent.getSelectScheme();
				if(str==null){
					JyyMsgBox.alert({ title:"提示", message:"请选择方案！", type:"info"}).on(function (e) {});
				}else{
					var code = str.code;
					JyyLoading.start();
					$.ajax({
						type:"POST",
						url:"../pv/executive/tzxqExe",
						data:{versionid:code,type_1:'tzxq'},
						success:function(data){
							JyyLoading.end();
							JyyMsgBox.alert({ title:"提示", message:data.msg, type:"info"}).on(function (e) {});
						}
					});
				}
			}else if(data.data.code == "tznl"){
				var str = parent.getSelectScheme();
				if(str==null){
					JyyMsgBox.alert({ title:"提示", message:"请选择方案！", type:"info"}).on(function (e) {});
				}else{
					var code = str.code;
					JyyLoading.start();
					$.ajax({
						type:"POST",
						url:"../pv/executive/tznl1Exe",
						data:{versionid:code,type_1:'tznl'},
						success:function(data){
							JyyLoading.end();
							JyyMsgBox.alert({ title:"提示", message:data.msg, type:"info"}).on(function (e) {});
						}
					});
				}
			}else if(data.data.code == "tnzl"){
				JyyLoading.start();
				$.ajax({
					type:"POST",
					url:"../pv/executive/tznlExe",
					data:{versionid:parent.getSelectScheme().code,type_1:"tnzl"},
					success:function(data){
						JyyLoading.end();
						if(data.flag == 0){
							JyyLoading.end();
							JyyMsgBox.alert({ title:"提示", message:"计算成功!", type:"info"}).on(function (e) {});
						}else{
							JyyLoading.end();
							JyyMsgBox.alert({ title:"提示", message:"计算成功!", type:"info"}).on(function (e) {});
						}
					}
				});
			}
		}
	} else if(res.id == "seeBpa"){
		var url = jyyMain.getUrl(data.data.code);
		if(data.data.code == "wpOutput"){
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:data.data.code, name:"风电出力重构", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"风电出力重构", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}else if(data.data.code == "pvOutput"){
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:data.data.code, name:"光伏出力重构", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"光伏出力重构", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}else if(data.data.code == "powerBalance"){
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:data.data.code, name:"电力平衡分析", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"电力平衡分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}else if(data.data.code == "cellBalance"){
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:data.data.code, name:"电量平衡分析", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"电量平衡分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}else if(data.data.code == "unitUtilizationAnalys"){
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:data.data.code, name:"机组利用分析", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"机组利用分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}else if(data.data.code == "renewableEnergyAnalys"){
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:data.data.code, name:"可再生能源消纳分析", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"可再生能源消纳分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}else if(data.data.code == "lineSectionAnalys"){
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:data.data.code, name:"线路断面分析", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"线路断面分析", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}else if(data.data.code == "systemPositionMap"){
			var code = $("#SelectSchemeName option:selected").val();
			parent.addTab({id:data.data.code, name:"系统工作位置图", url:url + "&projectid=" + code, closable:true, active:true});
			/*window.modal = jyyModal.open("modal/planChoosePage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("选 择 方 案");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").on("click",function(){
					var code = $("#SelectSchemeName option:selected").val();
					parent.addTab({id:name, name:"系统工作位置图", url:url + "&projectid=" + code, closable:true, active:true});
					window.modal.close();
				});
			});*/
		}else if(data.data.code =="planning2"){
			window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205,title:"柔性优化规划"},function(){
				$("#cancelScheme").on("click",function(){window.modal.close();});
				$("#saveScheme").on("click",function(){
					//var isTrue = jyyMain.checkDatFile(true);
					var isTrue = true;
					if(isTrue){
						parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
						parent.setBpaResultName($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.name);
						parent.setSelectBpaSchemeCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
						//JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
						parent.addTab({id:"planningShow", name:"柔性规划结果展示", url:"planningShowPage.html", closable:true, active:true});
						window.modal.close();
					}
				})
			});
		}else if(data.data.code =="tzxq"){
			parent.addTab({id:data.data.code, name:"投资需求", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
		}else if(data.data.code =="tznl"){
			parent.addTab({id:data.data.code, name:"投资能力", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
		}else if(data.data.code =="staticSecurityAnalys"){
			parent.addTab({id:data.data.code, name:"静态安全分析", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
		}else if(data.data.code =="StableParamCheck"){
			parent.addTab({id:data.data.code, name:"稳定参数校验", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
		}else if(data.data.code =="batchCalculate"){
			parent.addTab({id:data.data.code, name:"批量稳定计算", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
		}else if(data.data.code =="flowParamCheck"){
			parent.addTab({id:data.data.code, name:"潮流参数校验", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
		}else if(data.data.code =="flowConvergenceTrim"){
			parent.addTab({id:data.data.code, name:"潮流收敛调整", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
		}else if(data.data.code =="flowResultAnalys"){
			parent.addTab({id:data.data.code, name:"潮流结果分析", url:url + "&projectid=" + parent.getSelectScheme().code, closable:true, active:true});
		}else{
			window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:"电气计算结果选择"}, function(){
				$("#cancelScheme").on("click", function(){window.modal.close();});
				$("#saveScheme").on("click", function(){
					parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					parent.addTab({id:data.data.code, name:data.data.name, url:url + "&projectid=" + parent.getBpaResultCode(), closable:true, active:true});
					window.modal.close();
				});
			});
		}
	} else if(res.id == "network"){
		window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:"电气计算结果选择"}, function(){
			$("#cancelScheme").on("click", function(){window.modal.close();});
			$("#saveScheme").on("click", function(){
				parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
				parent.setBpaResultName($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.name);
				parent.setParentPageName(res.id);
				parent.addTab({id:data.data.code + "_network", name:"网架图", url:"network.html?type=wjt", closable:true, active:true});
				window.modal.close();
			});
		});
	}else if(res.id == "GOPTDataConvert"){
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{

			window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:"电气计算结果选择"}, function(){
				$("#cancelScheme").on("click", function(){window.modal.close();});
				$("#saveScheme").on("click", function(){
					parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					window.modal.close();
					window.modal = jyyModal.open("modal/converExcel.html", {width:450, height:240, title:"运行模拟数据生成"}, function(){
						$("#convertForm").attr("action", "../pv/convertExcel/convert");
						$('#divBpaFile > label').html('<span class="text-danger">*</span>潮流文件->运行模拟数据');
						$("#closeDiv").on("click", function(){window.modal.close();});
						$("#convertExcel").text("数 据 转 换");
						$("#divSwiFile").remove();
						$("#divVoltValue").show();
						$("#convertExcel").on("click", function(){
							//var isTrue = jyyMain.checkDatFile(false);
							var isTrue = true;
							if(isTrue){
								$("#versionidForC").val(parent.getBpaResultCode());
								$("#convertForm").submit();
								window.modal.close();
							}
						});
					});
				});
			});
		}
	}else if(res.id == "planSchemeGeneration"){
		parent.setParentPageName(res.id);
		parent.addTab({id:data.data.code + "_network", name:"方案生成", url:"network.html?type=fasc", closable:true, active:true});
	}else if(res.id == "tsepPlanLine"){
		parent.addTab({id:data.data.code + "_planLine", name:"柔性数据管理", url:"tsepPlanLinePage.html", closable:true, active:true});
	}else if(res.id == "planSchemeLinked"){
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
		}else{
			window.modal = jyyModal.open("modal/dataImportPage.html", {width:350, height:150, title:this.innerText}, function(){
				$("#convertExcel").text("数 据 导 入");	
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#userName").val(parent.user.userName);
				$("#schemeid").val(parent.getSelectScheme().code);
				$("#parentCode").val("planSchemeLinked");
				$("#convertExcel").on("click",function(){
					var options = $("#SelectSchemeName option:selected");
					$("#bpaSchemeid").val(options[0].value);
					$("#uploadAll").click();
				});
			});
		}
	}else if(res.id == "calByLocation"){//上传DAT并计算 稳定参数校验
		if(data.data.code == "flowParamCheck" || data.data.code == "flowConvergenceTrim" 
			|| data.data.code == "flowResultAnalys" || data.data.code == "StableParamCheck"){//潮流参数校验
			window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:data.data.name}, function(){
				$("#cancelScheme").on("click", function(){window.modal.close();});
				$("#saveScheme").on("click", function(){
					$("#type_1").val("E1");
					$("#type_2").val(data.data.code);
					$("#versionidForExe").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
					$("#projectidForExe").val(parent.getSelectScheme().code);
					$("#bpaResultid").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					$("#userNameForExe").val(parent.user.userName);
					parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					window.modal.close();
					var heightV =180;
					if(data.data.code == "StableParamCheck"){
						heightV = 250;
					}
					window.modal = jyyModal.open("modal/converExcel.html",{width:450, height:heightV, title:data.data.name}, function(){
						$("#convertForm").attr("action", "../pv/executive/uploadDatFile");
						$("#convertExcel").text("执 行 计 算");
						if(data.data.code == "StableParamCheck"){
						}else{
							$("#divSwiFile").remove();
						}
						$("#closeDiv").on("click",function(){window.modal.close();});
						$("#convertExcel").on("click", function(){
							var isTrue = jyyMain.checkDatFile(true);
							if(isTrue){
								var fileName = $("#bpa").val();
								if(fileName!=""&&fileName!='undefined'&&typeof(fileName) != undefined&&fileName!=undefined){
									fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length);
								}
								$("#type_1").val("E1");
								$("#type_2").val(data.data.code);
								$("#versionid").val(jyyMain.selectScheme.code);
								$("#projectid").val(parent.getSelectScheme().code);
								$("#fileName").val(fileName);
								$("#bpaResultid").val(parent.getBpaResultCode());
								JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
								$("#convertForm").ajaxSubmit({
									success : function(res) {
										JyyLoading.end();
									}
								});
								window.modal.close();
								/*var fileName=$("#bpa").val();
								fileName=fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length);
								jyyMain.datImportdat("StableParamCheck",fileName);*/
							}
						});
					});
				});
			});
		}else if(data.data.code == "staticSecurityAnalys"){//静态安全分析
			window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:data.data.name}, function(){
				$("#cancelScheme").on("click", function(){window.modal.close();});
				$("#saveScheme").on("click", function(){
					$("#type_1").val("E1");
					$("#type_2").val(data.data.code);
					$("#versionidForExe").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
					$("#projectidForExe").val(parent.getSelectScheme().code);
					$("#bpaResultid").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					$("#userNameForExe").val(parent.user.userName);
					parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					window.modal.close();
					window.modal = jyyModal.open("modal/bpaSafetyAnaly.html",{width:1200, height:380, title:data.data.name}, function(){
						$("#saveParamsForSafe").text("执 行 计 算");
						$("#divBpaFileButton").remove();
						$("#closeParams").on("click",function(){window.modal.close();});
						$("#saveParamsForSafe").on("click", function(){
							$("#convertForm").attr("action", "../pv/executive/uploadDatFile");
							var isTrue = jyyMain.checkDatFile(true);
							if(isTrue){
								$("#operType").val("staticSecurityAnalys");
								var fileName = $("#bpaFile").val();
								fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length);
								$("#fileName").val(fileName);
								jyyMain.intervalObj = setInterval('jyyMain.exeBpaParams("staticSecurityAnalysIn")', 0.1 * 1000);
							}
						});
					});
				});
			});
		}
//		else if(data.data.code == "StableParamCheck"){//稳定参数校验
//			alert("稳定参数校验");
//		}
		else if(data.data.code == "batchCalculate"){//批量稳定计算
			/*window.modal = jyyModal.open("modal/bpaBatch.html",{width:700, height:460, title:"批量稳定计算"}, function(){
				$("#divBpaFileButton").remove();
				
				$("#closeParams").on("click", function(){window.modal.close();});
				$("#saveParamsForSafe").on("click", function(){
					debugger
					var fileName = $("#bpa").val();
					fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length);
					$("#fileName").val(fileName);
					jyyMain.intervalObj = setInterval('jyyMain.exeBpaParams("batchCalculateIn")', 0.1 * 1000);
				});
			});*/
			
			
			window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:data.data.name}, function(){
				$("#cancelScheme").on("click", function(){window.modal.close();});
				$("#saveScheme").on("click", function(){
					$("#versionidForExe").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
					$("#projectidForExe").val(parent.getSelectScheme().code);
					$("#bpaResultid").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					$("#userNameForExe").val(parent.user.userName);
					parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					window.modal.close();
					window.modal = jyyModal.open("modal/bpaBatch.html",{width:1200, height:460, title:"批量稳定计算"}, function(){
						$("#divBpaFileButton").remove();
						
						$("#closeParams").on("click", function(){window.modal.close();});
						$("#saveParamsForSafe").on("click", function(){
							$("#operType").val("batchCalculate");
							var fileName = $("#bpa").val();
							if(fileName!=""&&fileName!='undefined'&&typeof(fileName) != undefined&&fileName!=undefined){
								fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length);
							}
							$("#fileName").val(fileName);
							jyyMain.intervalObj = setInterval('jyyMain.exeBpaParams("batchCalculateIn")', 0.1 * 1000);
						});
					});
				});
			});
			
			
			
			
		}
		
	}else if(res.id == "putForER"){
		if(data.data.code == "tzxq"){
			window.modal = jyyModal.open("modal/putPageForER.html",{width:450, height:250, title:"投资需求"}, function(){
				$("#saveScheme").on("click",function(){
					var formData = new FormData();
					formData.append("fileCsv",$("#fileCsv")[0].files[0]);
					formData.append("fileHistory",$("#fileHistory")[0].files);
					var files = $("#fileHistory")[0].files;
				    for (var i=0;i<files.length;i++){
				    	formData.append('fileHistory',files[i]);
				    }
					window.modal.close();
					JyyLoading.start();
					$.ajax({
		                type: 'POST',
		                url: "../pv/page/tzxqDataInputFile",
		                data: formData,
		                cache: false,
		                processData: false,
		                contentType: false,
		                success: function (ret) {
		                	JyyLoading.end();
							JyyMsgBox.alert({ title:"提示", message:ret,type:"info"}).on(function (e) {});
		                },
		                error:function(){
		                	JyyLoading.end();
		                }
		            });
				});
				$("#cancelScheme").on("click",function(){window.modal.close();});
			});
		}else if(data.data.code == "tznl"){
			window.modal = jyyModal.open("modal/putPageForER.html",{width:450, height:175, title:"投资能力"}, function(){
				$("#historyDiv").hide();
				$("#saveScheme").on("click",function(){
					var formData = new FormData();
					formData.append("fileCsv",$("#fileCsv")[0].files[0]);
					window.modal.close();
					JyyLoading.start();
					$.ajax({
		                type: 'POST',
		                url: "../pv/page/tznlDataInputFile",
		                data: formData,
		                cache: false,
		                processData: false,
		                contentType: false,
		                success: function (ret) {
		                	JyyLoading.end();
							JyyMsgBox.alert({ title:"提示", message:ret,type:"info"}).on(function (e) {});
		                },
		                error:function(){
		                	JyyLoading.end();
		                }
		            });
				});
				$("#cancelScheme").on("click",function(){window.modal.close();});
			});
		}
	}else if(res.id ==  "dataImport"){//运行模拟数据导入
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			$("#userName").val(parent.user.userName);
			$("#schemeid").val(parent.getSelectScheme().code);
			$("#parentCode").val("dataImport");
			$("#uploadAll").click();
		}
		
	}else if(res.id ==  "dataConvert"){//运行模拟数据转换
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			window.modal = jyyModal.open("modal/converExcel.html", {width:450, height:360, title:this.innerText}, function(){
				$("#convertForm").attr("action", "../pv/convertExcel/convert");
				$('#divBpaFile > label').html('<span class="text-danger">*</span>潮流文件->运行模拟数据');
				$("#closeDiv").on("click", function(){window.modal.close();});
				$("#convertExcel").text("数 据 转 换");
				$("#divSwiFile").remove();
				$("#divVoltValue").show();
				$("#divDate1").show();
				$('#date1').datetimepicker({
			        format:"yyyy-mm-dd",minView:2,startView:2,todayBtn:1,autoclose:1
			    }).on('show', function(ev){
			    	var endTime = $(".form-control:eq(1)").val();
			    	if (endTime !== '') {
			            $(this).datetimepicker('setEndDate', endTime);
			        } else {
			            $(this).datetimepicker('setEndDate', null);
			        }
		        });
				$('#date2').datetimepicker({
			        format:"yyyy-mm-dd",minView:2,startView:2,todayBtn:1,autoclose:1
			    }).on('show', function(ev){
			    	var startTime = $('.form-control:eq(0)').val();
			        if (startTime !== '') {
			            $(this).datetimepicker('setStartDate', startTime);
			        } else {
			            $(this).datetimepicker('setStartDate', null);
			        }
		        });
				var Beginday = "2000-01-01";
				$('#date1').datetimepicker('update', Beginday);
				var Endday =  "2050-01-01";
				$('#date2').datetimepicker('update', Endday);
				$("#convertExcel").on("click", function(){
					//var isTrue = jyyMain.checkDatFile(false);
					var isTrue = true;
					if(isTrue){
						var startTime = $(".form-control:eq(0)").val().substr(0,10);
						var endTime = $(".form-control:eq(1)").val().substr(0,10);
						var fileInput = $('#bpa').get(0).files[0];
						if(JyyCommon.isEmpty(startTime)||JyyCommon.isEmpty(endTime)){
							JyyMsgBox.alert({ title:"警告", message:"规划时间不能为空!",type:"info"}).on(function (e) {});

						}else if(!fileInput || typeof(fileInput)=="undefined" || fileInput==null || fileInput=="undefined"){
							JyyMsgBox.alert({ title:"警告", message:"上传文件不能为空!",type:"info"}).on(function (e) {});
						}else{
							$("#versionidForC").val(jyyMain.selectScheme.code);
							$("#projectid").val(parent.getSelectScheme().code);
							$("#beginDate").val($(".form-control:eq(0)").val());
							$("#endDate").val($(".form-control:eq(1)").val());
							$("#from").val("yxsjdr");
							JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
							$("#convertForm").submit();
							/*$("#convertForm").ajaxSubmit(function(data){  
								debugger
								if(data){
									alert("dat文件错误！"+data);   
									//JyyMsgBox.alert({ title:"提示", message:"数据转换成功!", type:"info"}).on(function (e) {});
								}else{
									JyyMsgBox.alert({ title:"提示", message:"数据转换成功!", type:"info"}).on(function (e) {});
								}
								JyyLoading.end();
								window.modal.close();
							});*/
                            setTimeout(function(){JyyLoading.end();},10000);

							window.modal.close();
						}
					}
				});
			});
		}
	}else if(res.id ==  "Psdcljs" ||res.id ==  "wdjs"){//Psdedit
		if(jyyMain.canOpen != null && jyyMain.canOpen == 1){
			JyyMsgBox.alert({ title:"警告", message:"程序正在计算,请稍后!",type:"info"}).on(function (e) {});
		}else{
			/*window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:data.data.name}, function(){
				$("#cancelScheme").on("click", function(){window.modal.close();});
				$("#saveScheme").on("click", function(){
					$("#versionidForExe").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.nodeli.data.code);
					$("#projectidForExe").val(parent.getSelectScheme().code);
					$("#bpaResultid").val($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					$("#userNameForExe").val(parent.user.userName);
					parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
					window.modal.close();
					
				});
			});*/
			var param = [];
			param.push(res.id);
			param.push(parent.getSelectBpaScheme().code);
			param.push(parent.getSelectScheme().code);
			param.push(parent.user.userName);
			$.ajax({
				headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
				type: "post",
				dataType: "json", 
				url: "../pv/executive/Psdedit",
				data:JSON.stringify(param)
			}).done(function(res){
				if(res.flag == 1){
					JyyMsgBox.alert({ title:"提示", message:res.result,type:"info"}).on(function (e) {});
				}else{
					var param = [];
					param.push('pfo');
					param.push(parent.getSelectBpaScheme().code);
					param.push(parent.getSelectScheme().code);
					param.push(parent.user.userName);
					$.ajax({
						headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
						type: "post",
						dataType: "json", 
						url: "../pv/executive/Psdedit",
						data:JSON.stringify(param)
					}).done(function(res){
						if(res.flag == 1){
							JyyMsgBox.alert({ title:"提示", message:res.result,type:"info"}).on(function (e) {});
						}else{
							JyyMsgBox.alert({ title:"提示", message:res.result,type:"info"}).on(function (e) {});
						}
						JyyLoading.end();
					});
				}
				JyyLoading.end();
			});
		}
		
	}else if(res.id ==  "wdjg"){
		var param = [];
		param.push(res.id);
		param.push(parent.getSelectBpaScheme().code);
		param.push(parent.getSelectScheme().code);
		param.push(parent.user.userName);
		$.ajax({
			headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
			type: "post",
			dataType: "json", 
			url: "../pv/executive/getPsdedit",
			data:JSON.stringify(param)
		}).done(function(res){
			if(res.flag == 1){
				JyyMsgBox.alert({ title:"提示", message:res.result,type:"info"}).on(function (e) {});
			}else{

				window.modal = jyyModal.open("modal/bpatext.html", {width:800, height:500, title:this.innerText}, function(){
					var text = res.result;
					text = text.replace(/###/g,"\r\n");
					document.getElementById('panelTabs').innerHTML=text;
				});
			}
			JyyLoading.end();
		});
		
	}else if(res.id == "psdnetwork"){
		window.modal = jyyModal.open("modal/chooseBpaResultPage.html",{width:450, height:205, title:"电气计算结果选择"}, function(){
			$("#cancelScheme").on("click", function(){window.modal.close();});
			$("#saveScheme").on("click", function(){
				parent.setBpaResultCode($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.code);
				parent.setBpaResultName($("#selectBpaResultTree .rxtree_label_selected")[0].nodeli.data.name);
				parent.setParentPageName(res.id);
				parent.addTab({id:data.data.code + "_network", name:"网架图", url:"network.html?type=psdnetwork", closable:true, active:true});
				window.modal.close();
			});
		});
	}
}
//判断潮流收敛调整是否执行
jyyMain.isExe = function() {
	var result = false;
	var params = {};
	$.ajax({
		async: false, 
		dataType: "json", 
		url: "../pv/executive/isExe", 
		data:{versionid:parent.getSelectBpaScheme().code}
	}).done(function(res){
		console.log(res.result);
		result = res.result
	})
	return result;
}
//判断风电光伏出力重构参数页面是否执行完毕，执行完毕则初始化参数信息。
jyyMain.isOk = function() {
	if(!isOk) return;
	clearInterval(jyyMain.intervalObj);
	//获取风电光伏参数
	var params = jyyMain.getParames();
	setParams(params);
}
//初始化静态安全分析表格参数信息
jyyMain.initParamsTableInfo = function() {
	if(!isOk) return;
	clearInterval(jyyMain.intervalObj);
	$.ajax({
		async: true, 
		dataType: "json", 
		url: "../pv/main/getParamsTableInfo", 
		data:{versionid:parent.getSelectBpaScheme().code}
	}).done(function(res){
		refreshTable(res.result);
	})
}
//潮流文件生成
jyyMain.exeACflowgeneration = function(name) {
	if(!isOk) return;
	clearInterval(jyyMain.intervalObj);
	var isTrue = check();
	if(isTrue){
		var params = getParams();
		JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
		$.ajax({
			url:"../pv/main/getFlowInfo",
			async:false,
			type:"POST",
			data:{"userNameForExe":parent.user.userName,"projectidForExe":parent.getSelectScheme().code,"versionidForExe":parent.getSelectBpaSchemeCode()}
		});
		$.ajax({
			headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
			type: "post",
			dataType: "json", 
			url: "../pv/executive/ACflowgenerationIn", 
			data:JSON.stringify(params)
		}).done(function(res){
			if(res.flag == 0){
				$.ajax({
					type: "post",
					dataType: "json", 
					url: "../pv/executive/expACflowgeneration",
					data:{type_1:"E1", type_2:name, versionid:parent.getSelectBpaSchemeCode(), projectid:parent.getSelectScheme().code,resultName:parent.getSelectBpaResultName(),"userName":parent.user.userName}
				}).done(function(res){
					if(res.flag == 1){
						jyyMain.refreshTree();
						JyyLoading.end();
						JyyMsgBox.alert({ title:"提示", message:"该电气计算名称已存在",type:"info"}).on(function (e) {});
					}else{
						$("#versionid").val(parent.getSelectBpaSchemeCode());
						$("#projectid").val(parent.getSelectScheme().code);
						$("#resultName").val(parent.getSelectBpaResultName());
						$("#userNameForout").val(parent.user.userName);
						jyyMain.refreshTree();
						JyyLoading.end();
						window.modal.close();
						$("#acFlowForm").submit();
					}
				})
			}
		})
	}
}
//获取静态安全分析、批量稳定计算 参数信息，并执行程序
jyyMain.exeBpaParams = function(name) {
	clearInterval(jyyMain.intervalObj);
	var oldParams = getParams();
	var params = [];
	var num = 9;
	if(name == "batchCalculateIn"){
		params[0] = oldParams[0];
		params[1] = oldParams[1];
		params[2] = oldParams[2];
		params[3] = oldParams[3];
		params[4] = oldParams[4];
		params[5] = oldParams[5];
		params[6] = oldParams[6];
		params[7] = oldParams[7];
		params[8] = oldParams[8];
	}else{
		params[0] = oldParams[0];
		params[1] = oldParams[1];
		num = 2;
	}
	var paramsList = $("#jyytable").find("tbody .warning td:nth-child(2)");
	if(name=='staticSecurityAnalysIn'||name=='batchCalculateIn'){
			for(var r = 0 ; r < $("#waitPlan")[0].length ; r++){
				params[r+num] =$("#waitPlan")[0][r].value;
			 }
	}else{
		
		for (var i = 0; i < paramsList.length; i++) {
			params[i+num] = $("#jyytable").find("tbody .warning td:nth-child(2)")[i].innerHTML;
		}
	}
	
	JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
	$.ajax({
		headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
		type: "post",
		dataType: "json", 
		url: "../pv/executive/" + name, 
		data:JSON.stringify(params)
	}).done(function(res){
		if(res.flag == 0){
			var fileName=$("#bpa").val();
			if(fileName!=""&&fileName!='undefined'&&typeof(fileName) != undefined&&fileName!=undefined){
				fileName=fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length);
				jyyMain.upAndDelDatFile(name,fileName);
			}else{
				jyyMain.expBpa(name);
			}
		}else{
			JyyLoading.end();
			JyyMsgBox.alert({ title:"提示", message:res.msg, type:"info"}).on(function (e) {});
		}
	})
}
jyyMain.expBpa = function(name) {
	$("#convertForm").attr("action","../pv/executive/expBpa");
	$("#type_1").val("E1");
	$("#type_2").val(name.replace("In",""));
	$("#versionidForExe").val(parent.getSelectBpaSchemeCode());
	$("#projectidForExe").val(parent.getSelectScheme().code);
	$("#userNameForExe").val(parent.user.userName);
	$("#bpaResultid").val(parent.getBpaResultCode());
	$("#convertForm").ajaxSubmit({
		success : function(res){
			window.modal.close();
			JyyLoading.end();
		}
	});
	

}
//删除dat swi文件
jyyMain.upAndDelDatFile = function(name,fileName) {
	$("#convertForm").attr("action","../pv/main/upAndDelDatFile");
	$("#type_1").val("E1");
	$("#type_2").val(name.replace("In",""));
	$("#versionidForExe").val(parent.getSelectBpaSchemeCode());
	$("#projectidForExe").val(parent.getSelectScheme().code);
	$("#userNameForExe").val(parent.user.userName);
	$("#bpaResultid").val(parent.getBpaResultCode());
	$("#fileNameDat").val(fileName);
	var fileSwi = $("#swi").val();
	if(fileSwi!=""&&fileSwi!='undefined'&&typeof(fileSwi) != undefined&&fileSwi!=undefined){
		fileSwi = fileSwi.substring(fileSwi.lastIndexOf("\\") + 1, fileSwi.length);
	}
	$("#fileNameSwi").val(fileSwi);
	$("#convertForm").ajaxSubmit({
		success : function(res){
			jyyMain.datImportdat(name,fileName);
		}
	});
	

}
//上传文件
jyyMain.datImportdat = function(name,fileName) {
	$("#convertForm").attr("action","../pv/main/datImportdat");
	$("#type_1").val("E1");
	$("#type_2").val(name.replace("In",""));
	$("#versionidForExe").val(parent.getSelectBpaSchemeCode());
	$("#projectidForExe").val(parent.getSelectScheme().code);
	$("#userNameForExe").val(parent.user.userName);
	$("#bpaResultid").val(parent.getBpaResultCode());
	$("#fileNameDat").val(fileName);
	var fileSwi = $("#swi").val();
	if(fileSwi!=""&&fileSwi!='undefined'&&typeof(fileSwi) != undefined&&fileSwi!=undefined){
		fileSwi = fileSwi.substring(fileSwi.lastIndexOf("\\") + 1, fileSwi.length);
	}
	$("#fileNameSwi").val(fileSwi);
	$("#convertForm").ajaxSubmit({
		success : function(res){
			jyyMain.expBpa(name);
			//jyyMain.upAndDelDatFile(name,fileName);
		}
	});
	

}



//获取gopt系统参数
jyyMain.getParames = function() {
	var params = {};
	$.ajax({async: false, dataType: "json", url: "../pv/main/getProject", data:{projectid:parent.getSelectBpaSchemeCode()}}).done(function(res){
		if(res.result){
			params = eval("("+res.result+")");
		}
	}).fail(function(data,status,xhr){
		//TODO
	})
	return params;
}
//获取柔性优化规划参数
jyyMain.getParamesForPlan = function() {
	var params = {};
	$.ajax({async: false, dataType: "json", url: "../pv/main/getProject", data:{projectid:parent.getSelectScheme().code}}).done(function(res){
		if(res.result){
			params = eval("("+res.result+")");
		}
	}).fail(function(data,status,xhr){
		//TODO
	})
	return params;
}
//存储gopt系统参数
jyyMain.setParames = function(params, obj) {
	var projectid = parent.getSelectBpaSchemeCode();
	var name = null;
	if(obj.name == "tsep"){
		projectid = parent.getBpaResultCode();
	}
	$.ajax({
		url: "../pv/main/updateProject",
		data:{projectid:projectid, data:JSON.stringify(params)}
	}).done(function(res){
		if(obj.name != "tsep"){
			jyyMain.expFun({type_1:"E2", type_2:obj.type, versionid:projectid, projectid:projectid, name:obj.name});
			JyyLoading.end();
		}else{
			$.ajax({
				url:"../pv/executive/expTsep",
				data:{versionid:parent.getBpaResultCode(),projectid:parent.getSelectScheme().code,newPlanName:params.newPlanName,userName:jyyMain.user.userName},
				type:"POST",
				success:function(res){
					JyyLoading.end();
					if(res.flag == 0){
				    	JyyMsgBox.alert({ title:"提示", message:"数据计算成功!",type:"info"}).on(function (e) {});
					}else{
				    	JyyMsgBox.alert({ title:"提示", message:"数据计算失败!",type:"info"}).on(function (e) {});
					}
				}
			});
		}
	}).fail(function(data,status,xhr){
		JyyLoading.end();
	})
}
//单选框点击回调事件
//jyyMain.onRadioClick = function(){
//	jyyMain.isShow = true;
//}
//获取系统参数并生成csv存储到平台指定目录中
/*jyyMain.buildParamesCsv = function(type) {
	$.ajax({dataType: "json", url: "../pv/main/convertParams", data:{schemeid:parent.getSelectScheme().code,type:type}}).done(function(res){
		if(type == "E1"){
			jyyMain.expFun({type_1:"E2", type_2:"simulation", versionid:jyyMain.selectScheme.code, projectid:parent.getSelectScheme().code});
		}else{
			jyyMain.expFun({type_1:"E2", type_2:"restructure", versionid:jyyMain.selectScheme.code, projectid:parent.getSelectScheme().code});
		}
	}).fail(function(data,status,xhr){
		JyyLoading.end();
	})
}*/
//全量上传事件
jyyMain.uploadAll = function(event){
	if(event.value == ""){
		return;
	}
	JyyLoading.start();
	$("#uploadForm").ajaxSubmit({
		success : function(data) {
			$("#uploadAll").val("");
			JyyMsgBox.alert({ title:"提示", message:data,type:"warning"}).on(function (e) {});
			JyyLoading.end();
		}
	});
}
//核查潮流文件正确性
jyyMain.checkDatFile = function(isSwi) {
	var files = $("#bpa")[0].files;
	
	if(files.length == 0){
		JyyMsgBox.alert({ title:"提示", message:"请选择潮流文件!",type:"info"}).on(function (e) {});
		return false;
	}
	
	var patternFileExtension = /\.([0-9a-z]+)(?:[\?#]|$)/i;
	for(var i = 0; i < files.length; i++){
		var fileName = files[i].name;
		
		var ext = fileName.match(patternFileExtension);
		if(ext[1].toLowerCase() != "dat"){
			JyyMsgBox.alert({ title:"提示", message:"请选择潮流文件!",type:"info"}).on(function (e) {});
			return false;
		}
	}
	if(isSwi){
		var divSwiFile = $("#divSwiFile");
		if(divSwiFile.length != 0){
			var val = $("#swi").val();
			if(JyyCommon.isEmpty(val)){
				JyyMsgBox.alert({ title:"提示", message:"请选择swi文件!",type:"info"}).on(function (e) {});
				return false;
			}
			
			var ext = val.match(patternFileExtension);
			if(ext[1].toLowerCase() != "swi"){
				JyyMsgBox.alert({ title:"提示", message:"请选择swi文件!",type:"info"}).on(function (e) {});
				return false;
			}
		}
	}
	
	return true;
}
//判断运行模拟是否有数据
jyyMain.isExistsGoptData = function(code){
	var result=null;
	$.ajax({
		async: false,
		dataType: "json",
		url: "../pv/main/isExistence/" + code
	}).done(function(res) {
		result = res.result;
	});
	return result;
}
//执行程序
jyyMain.expFun = function(data) {
	JyyLoading.start({loadingTips: "正在执行程序，请稍候..."});
	if(data.type_1 == "E2"){
		JyyLoading.end();
		//展示进度窗口
		window.modal = jyyModal.open("modal/goptProgress.html", {width:496, height:550, title:"计算进程", isCanMin:true}, function(){
			
			$("#progressState").loadStep({
				size: "large",
		      	color: "green",
		      	steps: [
		      		{title: "新能源", content: "可再生能源运行模拟"},
		      		{title: "水电",content: "长期水电运行模拟"},
		      		{title: "检修",content: "检修运行模拟"},
		      		{title: "日运行",content: "逐日运行模拟"},
		      		{title: "计算结果",content: "导入计算结果"}
		      	]
		    });
		    $("#progressState").setStep(1);
		    
		    //循环查看状态
		    var t = setInterval(function(){
		    	$.ajax({
		            url: '../pv/executive/getProgressInfo',
		            dataType: 'text'
		        }).done(function(res) {
		        	var r = eval("("+res+")");
		        	$('#progressStrip').css({width:r.progressBar+"%"});
		        	$('#progressStrip').find("span").text(r.progressBar + "%");
		        	$('#progressText').html(r.result);
		        	$('#progressText')[0].scrollTop = $('#progressText')[0].scrollHeight;
		        	$("#progressState").setStep(r.progressState);
				jyyMain.windowType = 1;
		   		jyyMain.canOpen = 1;
		    	});
		    }, 1000);
		    
		    var implementExe = $.ajax({dataType: "json", url: "../pv/executive/newThread", data:data}).done(function(res){
		    	clearInterval(t);
			jyyMain.windowType = 0;
		    	JyyMsgBox.alert({ title:"提示", message:"数据计算成功!",type:"info"}).on(function (e) {});
				$('#progressStrip').css({width:"100%"});
	        	$('#progressStrip').find("span").text("100%");
				$('#progressText').html(res.result);
	        	$('#progressText')[0].scrollTop = $('#progressText')[0].scrollHeight;
	        	$("#progressState").setStep(5);
	        	if(data.name=='exeDsedH'){
	        		$.ajax({
	        			async: false,
	        			dataType: "json",
	        			data:{projectid:data.projectid},
	        			url: "../pv/executive/callOperatePosition/" 
	        		}).done(function(res) {
	        			result = res.result;
	        		});
	        	}
	        	
			}).fail(function(data,status,xhr){
				clearInterval(t);
				jyyMain.windowType = 0;
			});
		    
		    $("#close" + window.modal.modal.id).unbind("click").on("click",function(){
		    	jyyMain.newId = this.id;
		    	//jyyMain.windowType为1时，证明程序正在执行，若jyyMain.windowType为0时，证明程序执行完毕
		    	if(jyyMain.windowType != null && jyyMain.windowType == 1){
					JyyMsgBox.confirm({ title:"提示", message:"确定结束进程么？",type:"warning"}).on(function (e) {
						if (e) {
							jyyMain.windowType = 0;
							clearInterval(t);
							implementExe.abort();
							//TODO jyyMain.killProcess(data.name);
							jyyMain.killProcess(data.name);
							window.modal.closeById(jyyMain.newId.slice(5));
							jyyMain.canOpen = 0;
						}
					});
		    	}else{
		    		jyyMain.windowType = 0;
		    		clearInterval(t);
					implementExe.abort();
//					jyyMain.killProcess(data.name);
					window.modal.closeById(this.id.slice(5));
					jyyMain.canOpen = 0;
		    	}
			});
		});
	}else{
		$.ajax({dataType: "json", url: "../pv/executive/implementExe", data:data}).done(function(res){
			JyyLoading.end();
		}).fail(function(data, status, xhr){
			JyyLoading.end();
		});
	}
}
//TODO 结束运行程序进程
jyyMain.killProcess = function(type){
	$.ajax({
		dataType: "json",
		data:{type:type},
		url: "../pv/executive/killProcess"
	}).done(function(res) {
		
	});
}
//获取dactive页面地址
jyyMain.getUrl = function(name){
	var url = null;
	var planId = '';
	if(parent.getSelectBpaScheme()!=null){
		planId = parent.getSelectBpaScheme().code;
	}else{
		planId = parent.getSelectScheme().code
	}
	if(name == "dataAnalys"){//数据分析
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=1";
	}else if(name == "wpOutput"){//风电出力重构
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=2";
	}else if(name == "pvOutput"){//光伏出力重构
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=3";
	}else if(name == "powerBalance"){//电力平衡分析
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=4";
	}else if(name == "cellBalance"){//电量平衡分析
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=5";
	}else if(name == "unitUtilizationAnalys"){//机组利用分析
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=6";
	}else if(name == "renewableEnergyAnalys"){//可再生能源消纳分析
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=7";
	}else if(name == "lineSectionAnalys"){//线路断面分析
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=8";
	}else if(name == "systemPositionMap"){//系统工作位置图
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=9";
	}else if(name == "flowParamCheck"){//潮流参数校验
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=10";
	}else if(name == "flowConvergenceTrim"){//潮流收敛调整
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=11";
	}else if(name == "flowResultAnalys"){//潮流结果分析
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=12";
	}else if(name == "staticSecurityAnalys"){//静态安全分析
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=13";
	}else if(name == "StableParamCheck"){//稳定参数校验
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=14";
	}else if(name == "batchCalculate"){//批量稳定计算
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=15";
	}else if(name == "ResultForE"){//机电——电磁暂态混合仿真
		url = "http://localhost/dactive/pages/report.jsp?type=501";
	}else if(name == "ResultForR"){//电网风险评估
		url = "http://localhost/dactive/pages/report.jsp?type=502";
	}else if(name == "tzxq"){//投资需求
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=16";
	}else if(name == "tznl"){//投资能力
		url = "http://localhost:"+window.location.port+"/platform/jyy/resultsDisplay.html?planId="+planId+"&sysType=17";
	}
	return url;
}
checkFileType = function (_this) {
	var $this = $(_this);
	var acceptType = $this.attr('accept');
	var selectedFile = $this.val();
	var fileType = selectedFile.substring(selectedFile.indexOf('.') + 1, selectedFile.length);
	var location = acceptType.indexOf(fileType);
	if (location > -1) {
		return true;
	} else {
		$("#DATData").val('');
		//$("#DATData").value=''
		alert('请选择'+acceptType+'格式文件');
		return;
	}
}
checkFileType1 = function (_this) {
	var $this = $(_this);
	var acceptType = $this.attr('accept');
	var selectedFile = $this.val();
	var fileType = selectedFile.substring(selectedFile.indexOf('.') + 1, selectedFile.length);
	var location = acceptType.indexOf(fileType);
	if (location > -1) {
		return true;
	} else {
		$("#SWIData").val('');
		//$("#DATData").value=''
		alert('请选择'+acceptType+'格式文件');
		return;
	}
}
checkFileType2 = function (_this) {
	var $this = $(_this);
	var acceptType = $this.attr('accept');
	var selectedFile = $this.val();
	var fileType = selectedFile.substring(selectedFile.indexOf('.') + 1, selectedFile.length);
	var location = acceptType.indexOf(fileType);
	if (location > -1) {
		return true;
	} else {
		$("#bpa").val('');
		//$("#DATData").value=''
		alert('请选择'+acceptType+'格式文件');
		return;
	}
}

jyyMain.init();